package netty.http;

import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.socket.SocketChannel;
import io.netty.handler.codec.http.HttpServerCodec;

/**
 * @author 帅小伙
 * @date 2022/1/16
 * @description
 */
public class TestServerInitializer extends ChannelInitializer<SocketChannel> {
    @Override
    protected void initChannel(SocketChannel ch) throws Exception {
        //向管道加入处理器
        ChannelPipeline pipeline = ch.pipeline();

        // 加入一个netty  提供一个HttpServerCodec
        // 提供的一个http编码解码器
        pipeline.addLast("myHttpServerCodec",new HttpServerCodec());

        // 添加一个自定义handler
        pipeline.addLast("myTestHttpServerHandler",new TestHttpServerHandler());
        System.out.println("hel");
    }
}
